ENG-1574: Add dual-read console logs to setting setters#914
Conversation
Log legacy and block prop values with match/mismatch status when a setting is changed. Fix broken import in storedRelations.
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
Log all legacy vs block prop settings on init. Remove setter logging. Expose dgDualReadLog() on window for on-demand use.
JSON.stringify is key-order dependent, causing false mismatches when legacy and block props return keys in different order.
|
@coderabbitai full review |
✅ Actions performedFull review triggered. |
📝 WalkthroughWalkthroughExports Changes
Sequence DiagramsequenceDiagram
participant initSchema as initSchema Function
participant legacyReader as Legacy Settings Reader
participant newReader as New Store Reader
participant deepEqual as deepEqual Comparator
participant logger as logDualReadComparison
participant console as Console/Window
initSchema->>initSchema: Check if new settings store enabled
alt New store enabled
initSchema->>legacyReader: Read legacy feature flags, global, personal, per-node settings
legacyReader-->>initSchema: Legacy settings payload
initSchema->>newReader: Read corresponding block-props/new-store values
newReader-->>initSchema: New store payload
initSchema->>logger: Call logDualReadComparison
logger->>deepEqual: Compare legacy vs new (exclude flag)
deepEqual-->>logger: Mismatch results
logger->>logger: Aggregate mismatches by type
logger->>console: Log summary and full payloads
console-->>logger: Logged
initSchema->>console: Expose logDualReadComparison as window.dgDualReadLog
else New store disabled
initSchema->>initSchema: Skip dual-read comparison
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
apps/roam/src/components/settings/utils/init.ts (1)
344-349: Avoid duplicating the feature-flag string literal.Line 348 hardcodes
"Use new settings store", while the same key is also hardcoded inapps/roam/src/components/settings/utils/accessors.ts. Centralizing this key as a shared constant will prevent drift if the flag name changes.♻️ Suggested refactor
+// e.g. from zodSchema or a shared settings-keys module +import { USE_NEW_SETTINGS_STORE_FLAG } from "./zodSchema"; const omitStoreFlag = ( flags: Record<string, unknown>, ): Record<string, unknown> => Object.fromEntries( - Object.entries(flags).filter(([k]) => k !== "Use new settings store"), + Object.entries(flags).filter(([k]) => k !== USE_NEW_SETTINGS_STORE_FLAG), );🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/roam/src/components/settings/utils/init.ts` around lines 344 - 349, The hardcoded feature flag string "Use new settings store" is duplicated; introduce a single exported constant (e.g., NEW_SETTINGS_STORE_FLAG) in a shared module and replace the literal in the omitStoreFlag function and the matching reference in accessors.ts with that constant (update imports accordingly); ensure the constant name is used in Object.entries(...).filter(([k]) => k !== NEW_SETTINGS_STORE_FLAG) inside omitStoreFlag and in any accessor functions that previously referenced the literal.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@apps/roam/src/components/settings/utils/init.ts`:
- Around line 344-349: The hardcoded feature flag string "Use new settings
store" is duplicated; introduce a single exported constant (e.g.,
NEW_SETTINGS_STORE_FLAG) in a shared module and replace the literal in the
omitStoreFlag function and the matching reference in accessors.ts with that
constant (update imports accordingly); ensure the constant name is used in
Object.entries(...).filter(([k]) => k !== NEW_SETTINGS_STORE_FLAG) inside
omitStoreFlag and in any accessor functions that previously referenced the
literal.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: f9358337-3c1f-4b25-9aeb-92b543c8f329
📒 Files selected for processing (2)
apps/roam/src/components/settings/utils/accessors.tsapps/roam/src/components/settings/utils/init.ts
We now print all settings on init and then can call the
window.dgDualReadLog()whenever we want to.Summary by CodeRabbit
New Features
Refactor